


import { ConfigKey } from "./config.type";

import { deepMergeKey } from "../other/deep";
import { Config } from "./config.type";


export class ConfigService {
    private config: Config;
    constructor() {
        this.config = {}
    }
    get<T extends ConfigKey>(componentName: T, key?: string): Config[T] {
        const res = ((this.config[componentName] as { [key: string]: unknown }) || {}) as any;
        return key ? { [key]: res[key] } : res;
    }
    merge<T extends ConfigKey>(componentName: T, ...defaultValues: Array<Config[T]>): Config[T] {
        return deepMergeKey({}, true, ...defaultValues, this.get(componentName));
    }
}


